<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=3,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>维修师傅客户端</title>
    <link href="../css/reset-html5.css" rel="stylesheet">
    <link href="../css/mui.min.css" rel="stylesheet">
    <link href="../css/mui.picker.min.css" rel="stylesheet">
    <script src="../js/jquery-2.2.1.min.js"></script>
    <script src="../plugins/vue/vue.min.js"></script>
    <style>
        .btn-lg{
            padding: 10px 16px;
        }
        .mui-input-group .mui-button-row{
            height: auto;
            padding: 5px 0;
        }
    </style>
</head>
<body class="body-bg" id="main">
<img src="../images/logo.png" style="width: 100%">
<!--<h3 class="mui-text-center" style="margin: 50px 0">管理后台登录验证</h3>-->
<form class="mui-input-group mar-top" onsubmit="return false">
    <div class="mui-input-row">
        <label>手机号</label>
        <input type="tel" placeholder="请输入您的手机号码" id="phone">
    </div>
    <div class="mui-input-row">
        <label>验证码</label>
        <input type="tel" id="code" style="width: 32%;float: left" placeholder="请输入验证码"><button class="mui-btn mui-btn-warning" id="send_sms" style="float: left;width: auto;margin-top: 1px">发送验证码</button>
    </div>

    <div class="mui-button-row">
        <button class="mui-btn mui-btn-primary btn-lg" id="bandWeixin">确认认证</button>
    </div>
</form>
</body>
<!--<script src="../js/mui.min.js"></script>-->
<script src="../js/mui.picker.min.js"></script>
<script src="../js/base.js"></script>
<script>

    var submitPhone;

    function checkPhone(phone){
        if(!(/^1[34578]\d{9}$/.test(phone))){
            alert("手机号码有误，请重填");
            return false;
        }
        return true;
    }

    $('#send_sms').on('click',function(){
        var phone = $('#phone').val();
        if(checkPhone(phone)){
            sendSMS(phone);
            submitPhone = phone;
            $(this).addClass('mui-btn-grey').removeClass('mui-btn-warning').text('短信已发送');
        }else{

        }

    });

//短信发送
    function sendSMS(phone){
        var data = {};
        data.phone = phone;
        $.post('../index/admin.php?m=Home&c=Admin&a=getLoginPhoneCode',data,function(res){
            if(res.code==200){

            }else{
                alert(res.message);
            }
        },'json');

    }




    //认证维修管理员
    $('#bandWeixin').click(function(){
       var code =  $('#code').val();
        if(code.length!=4){
            alert('验证码格式有误，必须为4位');
            return false;
        }
       bandWeixin(submitPhone,code);
    });


            function bandWeixin(phone,code){
                var data = {};
                data.phone = phone;
                data.code = code;
                $.post('../index/admin.php?m=Home&c=Admin&a=bandWeixin',data,function(res){
                    if(res.code==200){
                        location.href = 'my_order.html';
                    }else{
                        alert(res.message);
                    }
                },'json');
            }
</script>
</html>